<template>
  <div>
    <div id="building"></div>
    <div class="fly">
      <van-form @submit="onSubmit">
        <van-field
          v-model="phone"
          name="手机号"
          label="手机号"
          placeholder="手机号"
          :rules="[{ required: true, message: '请填写登录手机号' }]"
        >
        </van-field>
        <div style="text-align: right;" >
          <router-link to="/reg" class="div1">没有账号?点击注册</router-link>
        </div>
        <van-field
          v-model="u_pwd"
          type="password"
          name="密码"
          label="密码"
          placeholder="密码"
          :rules="[{ required: true, message: '请填写密码' }]"
        >
        </van-field>
        <div style="text-align: right;" >
          <router-link to="/forget" class="div1">忘记密码?点击修改</router-link>
        </div>
        <div style="margin: 16px">
          <van-button round block type="info" native-type="submit"
            >点击登录</van-button
          >
        </div>
      </van-form>
    </div>
  </div>
</template>

<script>
import { Toast } from 'vant';
export default {
  data() {
    return {
      phone: "",
      u_pwd: "",
    };
  },
  methods: {
    onSubmit(values) {
      const { phone, u_pwd } = this;
      const url = "/v1/users/login";
      const params = `phone=${phone}&u_pwd=${u_pwd}`;
      this.axios.post(url, params).then((res) => {
        console.log(res);
        if (res.data.code == 200) {
          Toast.success('恭喜,登陆成功');
          setTimeout(() => {
            this.$router.push("/");
          }, 3000);
          
        } else {
          Toast.fail('抱歉,登录失败');
        }
      });
    },
  },
};
</script>

<style scoped>
.div1{
  color: red;
  font-size: 28px;
  transform: translateX(-5px);

}

#building {
  background: url("../assets/images/loginimg.png") center;
  opacity: 0.7;
  width: 100%;
  height: 100%;
}

.fly {
  position: absolute;
  width: 80%;
  left: 50%;
  transform: translateX(-50%);
  bottom: 100px;
  z-index: 100;
}
input:-internal-autofill-selected {
  background-color: -internal-light-dark(
    rgba(255, 255, 255, 0),
    rgba(70, 90, 126, 0)
  ) !important;
}
div/deep/.van-cell {
  background-color: transparent !important;
  border: 1px solid #fff8f8;
  margin-top: 20px;
  border-radius: 25px;
  width: 100%;
  height: 100px;
}
.van-cell::after {
  border-bottom: 0 solid #000;
}
div/deep/.van-field__body input {
  transform: translateY(-3px) !important;
  color: #fff;
  
  line-height: 60px;
  text-align: left;
}
div/deep/.van-field__error-message {
  transform: translateY(-20px);
}
div/deep/.van-button--small {
  transform: translate(20px, -5px) !important;
}
div/deep/.input1 .van-cell__value.van-field__value input.van-field__control {
  transform: translateY(-6px) !important;
}

div/deep/.van-field__label {
  
  color: #fff;
  line-height: 50px;
  text-align: center;
}
.van-button--info {
  width: 100%;
  
  color: #fff;
  font-size: 30px;
  background-color: #e81964;
  border: 1px solid #e81964;
}

</style>
